<template>
  <div class="zero-drift tapStyle secondary-page-mode">
    <div class="currency-mode-wrap">
      <div class="tablebox" style="height: 100%">
        <el-table
          :data="tableData"
          border
          height="100%"
          :span-method="objectSpanMethod"
          style="width: 100%">
          <el-table-column
            type="index"
            label="序号"
            :index="indexMethod"
            width="50">
          </el-table-column>
          <el-table-column
            prop="category"
            label="类别">
          </el-table-column>
          <el-table-column
            prop="parameter"
            label="参数名称">
          </el-table-column>
          <!--<el-table-column
            prop="state"
            label="状态">
            <template slot-scope="scope">
              <span v-if="scope.row.state === 0" class="abnormal"><i></i>超上限</span>
              <span v-if="scope.row.state === 1" class="normal"><i></i>正常</span>
              <span v-if="scope.row.state === 2">-</span>
            </template>
          </el-table-column>-->
          <el-table-column
            prop="currentValue"
            label="当前值">
          </el-table-column>
          <el-table-column
            prop="normalRange"
            label="正常范围">
          </el-table-column>
          <el-table-column
            prop="company"
            label="单位">
          </el-table-column>
         <!-- <el-table-column
            prop="uploadTime"
            label="上传时间">
          </el-table-column>-->
          <el-table-column
            prop="record"
            label="修改记录">
          </el-table-column>
          <el-table-column
            prop="operation"
            label="操作">
            <template slot-scope="scope">
              <el-button type='secondBtn' @click="setParameter">设置</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>

    <el-dialog
      width="280px"
      title="参数设置"
      :visible.sync="parameter" >
        <div class="parameter-wrap">
           <div class="parameter-row">
             <span class="label-text">当 前 值：</span>
             <div class="layoutBox" style="width:160px">
                <el-input v-model="currentValue" placeholder="请输入内容"></el-input>
             </div>
           </div>
          <div class="parameter-row">
            <span class="label-text">正常范围：</span>
            <div class="layoutBox" style="width:160px">
              <el-input v-model="normalRange" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="parameter-row">
            <span class="label-text">修 改 为：</span>
            <div class="layoutBox" style="width:160px">
              <el-input v-model="modifiedTo" placeholder="请输入内容"></el-input>
            </div>
          </div>
          <div class="parameter-row" style="text-align: center;margin-top: 20px;">
              <el-button>&nbsp; 确定 &nbsp;</el-button>
          </div>
        </div>
    </el-dialog>

  </div>
</template>

<script>
  export default {
    name: "",
    data() {
      return {
        timing:60,//倒计时秒数
        refreshTime:new Date().format('yyyy-MM-dd hh:mm:ss'),//页面数据刷新时间
        tableData:[{
          category: "化学需氧量",
          parameter: '消解温度',
          state:1,
          currentValue: 1,
          normalRange: 1,
          company:'1',
          uploadTime:'1',
          record:'1',
          operation:'1',
        },{
          category: "化学需氧量",
          parameter: '消解时长',
          state:0,
          currentValue: 1,
          normalRange: 1,
          company:'1',
          uploadTime:'1',
          record:'1',
          operation:'1',
        },{
          category: "化学需氧量",
          parameter: '量程上限',
          state:1,
          currentValue: 1,
          normalRange: 1,
          company:'1',
          uploadTime:'1',
          record:'1',
          operation:'1',
        },{
          category: "氨氮",
          parameter: '消解时长',
          state:2,
          currentValue: 1,
          normalRange: 1,
          company:'1',
          uploadTime:'1',
          record:'1',
          operation:'1',
        },{
          category: "氨氮",
          parameter: '量程上限',
          state:0,
          currentValue: 1,
          normalRange: 1,
          company:'1',
          uploadTime:'1',
          record:'1',
          operation:'1',
        }],
        parameter:false,
        currentValue:'',
        normalRange:'',
        modifiedTo:'',
      };
    },
    methods:{
      adda(inedx,prop,key){
        let name = this.tableData[inedx][prop];
        let row = 0;
        for(let i=inedx;i<this.tableData.length;i++){
          if(name == this.tableData[i][prop]){
            row++
          }else{
            break;
          }
        }
        this.tableData[inedx][key] = row;
        return row
      },
      objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        if (columnIndex == 1) {
          if(row.sf){
            return{
              colspan:1,
              rowspan:row.sf
            }
          }else{
            return{
              colspan:1,
              rowspan:0
            }
          }
        }
      },
      setParameter(){
        this.parameter = true;
      }
    },
    mounted(){
      // this.createdChart();
    },
    created() {
      this.$store.commit("setShowlefttree", true);
      for(let i=0;i<this.tableData.length;i++){
        let num = this.adda(i,'category','sf');
        i+=num-1
      }
    }
  };
</script>

<style scoped lang="less">
  .zero-drift .currency-mode-wrap{
    padding: 0;
    border: none;
    margin-top: 0;
    height: 100%;
  }
  .timing-text{
    font-size: 16px;
    b{
      display: inline-block;
      width: 24px;
    }
  }
  .fault,.abnormal,.normal{
    i{
      display: inline-block;
      vertical-align: middle;
      margin-bottom: 2px;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #c64522;
      margin-right: 3px;
    }
  }
  .abnormal i{
    background: #c64522;
  }
  .normal i{
    background: #67c622;
  }
  .fault i{
    background: #dfae1c;
  }
  .label-text{
    display: inline-block;
    width: 70px;
    vertical-align: middle;
  }
  .parameter-row{
    padding: 4px 0;
  }
</style>

